home *** CD-ROM | disk | FTP | other *** search
- /* fopen.c */
- #include <stdio.h>
- main()
- {
- FILE *infile;
- unsigned char buffer[81];
- /* Open the file. Note that we need two '\' because
- * backslash denotes the beginning of a C escape
- * sequence. */
- if ((infile = fopen("c:\\autoexec.bat", "r")) == NULL)
- {
- printf("fopen failed.\n");
- exit(0);
- }
- printf("Contents of c:autoexec.bat:\n");
- while (fgets(buffer, 80, infile) != NULL)
- {
- printf(buffer);
- }
- fclose(infile); /* Close file before exiting */
- }